package com.byedu.domain.course.vo;

import com.byedu.domain.course.WeiXinUserDO;
import org.springframework.util.StringUtils;

import java.io.Serializable;
import java.util.UUID;

/**
 * Created by jason on 2017/5/20.
 */
public class WeiXinUserVO implements Serializable{
    private static final long serialVersionUID = 8676400847415488935L;
    /*微信OPENID  主键*/
    private String openId;
    /*微信昵称*/
    private String nickname;
    /*微信头像*/
    private String headImgUrl;
    /*性别*/
    private int sex;
    /*省份*/
    private String province;
    /*市*/
    private String city;
    /*国家*/
    private String country;
    /*用户编号  bay_user表的主键*/
    private String userId;
    /*登录时间*/
    private String loginTime;
    /*记录创建时间  其实就是用户首次使用微信授权登陆的时间*/
    private String createdTime;
    /*是否为新用户*/
    private boolean newFlag;

    private String identifyCode;

    private String cellPhone;

    public String getIdentifyCode() {
        return identifyCode;
    }

    public void setIdentifyCode(String identifyCode) {
        this.identifyCode = identifyCode;
    }

    public String getCellPhone() {
        return cellPhone;
    }

    public void setCellPhone(String cellPhone) {
        this.cellPhone = cellPhone;
    }

    public WeiXinUserVO () {}

    public WeiXinUserVO (WeiXinUserDO weiXinUserDO) {
        this.openId = weiXinUserDO.getOpenId();
        this.nickname = weiXinUserDO.getNickname();
        this.headImgUrl = weiXinUserDO.getHeadImgUrl();
        this.sex = weiXinUserDO.getSex();
        this.province = weiXinUserDO.getProvince();
        this.city = weiXinUserDO.getCity();
        this.country = weiXinUserDO.getCountry();
        this.userId = weiXinUserDO.getUserId();
        this.loginTime = weiXinUserDO.getLoginTime();
        this.createdTime = weiXinUserDO.getCreatedTime();
        this.newFlag = weiXinUserDO.isNewFlag();
        this.identifyCode= weiXinUserDO.getIdentifyCode();
        this.cellPhone=weiXinUserDO.getCellPhone();
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }


    public String getHeadImgUrl() {
        return headImgUrl;
    }

    public void setHeadImgUrl(String headImgUrl) {
        this.headImgUrl = headImgUrl;
    }

    public int getSex() {
        return sex;
    }

    public void setSex(int sex) {
        this.sex = sex;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(String loginTime) {
        this.loginTime = loginTime;
    }

    public String getCreatedTime() {
        return createdTime;
    }

    public void setCreatedTime(String createdTime) {
        this.createdTime = createdTime;
    }


    public boolean isNewFlag() {
        return newFlag;
    }

    public void setNewFlag(boolean newFlag) {
        this.newFlag = newFlag;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        WeiXinUserVO that = (WeiXinUserVO) o;

        if (StringUtils.isEmpty(this.openId) || !openId.equals(that.openId)) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        if (!StringUtils.isEmpty(openId)) {
            return openId.hashCode();
        }

        return UUID.randomUUID().hashCode();
    }

    @Override
    public String toString() {
        return "WeiXinUserVO{" +
                "openId='" + openId + '\'' +
                ", nickname='" + nickname + '\'' +
                ", headImgUrl='" + headImgUrl + '\'' +
                ", sex=" + sex +
                ", province='" + province + '\'' +
                ", city='" + city + '\'' +
                ", country='" + country + '\'' +
                ", userId='" + userId + '\'' +
                ", loginTime='" + loginTime + '\'' +
                ", createdTime='" + createdTime + '\'' +
                ", newFlag=" + newFlag +
                ", identifyCode='" + identifyCode + '\'' +
                ", cellPhone='" + cellPhone + '\'' +
                '}';
    }
}
